<head>
    <base href="${basePath}">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="Mosaddek">
    <meta name="keyword" content="FlatLab, Dashboard, Bootstrap, Admin, Template, Theme, Responsive, Fluid, Retina">

    <title>开开荟后台系统</title>

    <!-- Bootstrap core CSS -->
    <link href="${basePath}/system/css/bootstrap.min.css" rel="stylesheet">
    <link href="${basePath}/system/css/bootstrap-reset.css" rel="stylesheet">
    <!--external css-->
    <link href="${basePath}/system/assets/font-awesome/css/font-awesome.css" rel="stylesheet"/>
    <!-- Custom styles for this template -->
    <link href="${basePath}/system/css/style.css" rel="stylesheet">
    <link href="${basePath}/system/css/style-responsive.css" rel="stylesheet"/>

    <link href="${basePath}/assets/global/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet"
          type="text/css"/>
    <link href="${basePath}/assets/global/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet"
          type="text/css"/>
    <link href="${basePath}/assets/global/plugins/uniform/css/uniform.default.css" rel="stylesheet"
          type="text/css"/>

    <link href="${basePath}/assets/admin/pages/css/login-soft.css" rel="stylesheet" type="text/css"/>
    <!-- END PAGE LEVEL SCRIPTS -->
    <!-- BEGIN THEME STYLES -->
    <link href="${basePath}/assets/global/css/components.css" rel="stylesheet" type="text/css"/>
    <link href="${basePath}/assets/global/css/plugins.css" rel="stylesheet" type="text/css"/>
    <link href="${basePath}/assets/admin/layout/css/layout.css" rel="stylesheet" type="text/css"/>
    <link href="${basePath}/assets/admin/layout/css/themes/default.css" rel="stylesheet" type="text/css"
          id="style_color"/>
    <link href="${basePath}/assets/admin/layout/css/custom.css" rel="stylesheet" type="text/css"/>
    <!-- END THEME STYLES -->

    <style type="text/css">
        p.error {
            color: #DE5959;
        }

        .form-signin input[type="text"].error, .form-signin input[type="password"].error {
            border-color: #b94a48;
            color: #b94a48;
            -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
            box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
        }

        input.error:focus {
            border-color: #953b39;
            color: #b94a48;
            -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #d59392;
            box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #d59392;
        }
    </style>
</head>

<body class="login">
<!-- BEGIN LOGO -->
<div class="logo">

    <a href="index.html">
        <img src="${basePath}/assets/admin/layout/img/logo-big.png" alt="logo" class="logo-default"/>
    </a>

    <h2 style="color: white">开开荟管理后台</h2>
</div>
<!-- END LOGO -->
<!-- BEGIN SIDEBAR TOGGLER BUTTON -->
<div class="menu-toggler sidebar-toggler">
</div>
<!-- END SIDEBAR TOGGLER BUTTON -->
<!-- BEGIN LOGIN -->
<div class="content">
    <!-- BEGIN LOGIN FORM -->
    <form class="login-form" onSubmit="return false;" id="loginForm" method="post">
        <h3 class="form-title">请登录</h3>

        <div class="alert alert-danger display-hide">
            <button class="close" data-close="alert"></button>
			<span>
			请输入用户名和密码. </span>
        </div>
        <div class="form-group">
            <!--ie8, ie9 does not support html5 placeholder, so we just show field title for that-->
            <label class="control-label visible-ie8 visible-ie9">Username</label>

            <div class="input-icon">
                <i class="fa fa-user"></i>
                <input class="form-control placeholder-no-fix" type="text" autocomplete="off" placeholder="用户名"
                       value="370406497@qq.com"
                       name="email" id="email"/>
            </div>
        </div>
        <div class="form-group">
            <label class="control-label visible-ie8 visible-ie9">Password</label>

            <div class="input-icon">
                <i class="fa fa-lock"></i>
                <input class="form-control placeholder-no-fix" type="password" autocomplete="off" placeholder="密码"
                       value="123456"
                       name="password" id="password"/>
            </div>
        </div>
        <div class="form-actions">
            <label class="checkbox">
                <input type="checkbox" name="remember" value="1"/> 记住我 </label>
            <button type="submit" class="btn blue pull-right">
                登陆 <i class="m-icon-swapright m-icon-white"></i>
            </button>
        </div>
        <div class="login-options">

            <!--
    <h4>其他方式登陆</h4>
    <ul class="social-icons">
        <li>
            <a class="facebook" data-original-title="facebook" href="#">
            </a>
        </li>
        <li>
            <a class="twitter" data-original-title="Twitter" href="#">
            </a>
        </li>
        <li>
            <a class="googleplus" data-original-title="Goole Plus" href="#">
            </a>
        </li>
        <li>
            <a class="linkedin" data-original-title="Linkedin" href="#">
            </a>
        </li>
    </ul>
     -->
        <#--</div>-->
        <#--<div class="forget-password">-->
        <#--<h4>忘记密码 ?</h4>-->

        <#--<p>-->
        <#--不用担心, 点击 <a href="javascript:;" id="forget-password">-->
        <#--找回 </a>-->
        <#--重置您的密码.-->
        <#--</p>-->
        <#--</div>-->
            <div class="create-account">
                <p>
                    <!--
         Don't have an account yet ?&nbsp; <a href="javascript:;" id="register-btn">
        Create an account </a>
         -->
                </p>
            </div>
    </form>
    <!-- END LOGIN FORM -->
</div>
<!-- END LOGIN -->
<!-- BEGIN COPYRIGHT -->
<div class="copyright">
    2015 &copy; Shanghai Hengling Software Co., Ltd.
</div>
<!-- END COPYRIGHT -->
<!-- BEGIN JAVASCRIPTS(Load javascripts at bottom, this will reduce page load time) -->
<!-- BEGIN CORE PLUGINS -->
<!--[if lt IE 9]>

<![endif]-->

<!-- HTML5 shim and Respond.js IE8 support of HTML5 tooltipss and media queries -->
<!--[if lt IE 9]>
<script src="${basePath}/system/js/html5shiv.js"></script>
<script src="${basePath}/system/js/respond.min.js"></script>
<![endif]-->
<script src="${basePath}/system/js/jquery.js"></script>
<script src="${basePath}/system/js/jquery.form.min.js"></script>
<script src="${basePath}/system/js/jquery.watermark.js"></script>
<script src="${basePath}/assets/global/plugins/jquery-migrate-1.2.1.min.js" type="text/javascript"></script>
<!-- IMPORTANT! Load jquery-ui-1.10.3.custom.min.js before bootstrap.min.js to fix bootstrap tooltip conflict with jquery ui tooltip -->
<script src="${basePath}/assets/global/plugins/jquery-ui/jquery-ui-1.10.3.custom.min.js"
        type="text/javascript"></script>
<script src="${basePath}/assets/global/plugins/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
<script src="${basePath}/assets/global/plugins/bootstrap-hover-dropdown/bootstrap-hover-dropdown.min.js"
        type="text/javascript"></script>
<script src="${basePath}/assets/global/plugins/jquery-slimscroll/jquery.slimscroll.js"
        type="text/javascript"></script>
<script src="${basePath}/assets/global/plugins/jquery.blockui.min.js" type="text/javascript"></script>
<script src="${basePath}/assets/global/plugins/jquery.cokie.min.js" type="text/javascript"></script>
<script src="${basePath}/assets/global/plugins/uniform/jquery.uniform.min.js" type="text/javascript"></script>
<!-- END CORE PLUGINS -->
<!-- BEGIN PAGE LEVEL PLUGINS -->
<script src="${basePath}/assets/global/plugins/jquery-validation/js/jquery.validate.min.js"
        type="text/javascript"></script>
<script src="${basePath}/assets/global/plugins/backstretch/jquery.backstretch.min.js"
        type="text/javascript"></script>
<script src="${basePath}/assets/global/plugins/select2/select2.min.js" type="text/javascript"></script>

<!-- END PAGE LEVEL PLUGINS -->
<!-- BEGIN PAGE LEVEL SCRIPTS -->
<script src="${basePath}/assets/global/scripts/metronic.js" type="text/javascript"></script>
<script src="${basePath}/assets/admin/layout/scripts/layout.js" type="text/javascript"></script>
<script src="${basePath}/assets/global/scripts/jquery.json-2.4.js" type="text/javascript"></script>
<script src="${basePath}/assets/global/scripts/serializeForm.js" type="text/javascript"></script>
<#--<script src="${basePath}/assets/admin/pages/scripts/user/login.js" type="text/javascript"></script>-->
<!-- END PAGE LEVEL SCRIPTS -->
<script>
    jQuery(document).ready(function () {
        Metronic.init(); // init metronic core components
        Layout.init(); // init current layout
        Login.init();
    });

    var Login = function () {

        var handleLogin = function () {
            $('.login-form').validate({
                errorElement: 'span', //default input error message container
                errorClass: 'help-block', // default input error message class
                focusInvalid: false, // do not focus the last invalid input
                rules: {
                    name: {
                        required: true
                    },
                    pwd: {
                        required: true
                    },
                    remember: {
                        required: false
                    }
                },

                messages: {
                    name: {
                        required: "用户名不能为空."
                    },
                    pwd: {
                        required: "密码不能为空."
                    }
                },

                invalidHandler: function (event, validator) { //display error alert on form submit
                    $('.alert-danger', $('.login-form')).show();
                },

                highlight: function (element) { // hightlight error inputs
                    $(element)
                            .closest('.form-group').addClass('has-error'); // set error class to the control group
                },

                success: function (label) {
                    label.closest('.form-group').removeClass('has-error');
                    label.remove();
                },

                errorPlacement: function (error, element) {
                    error.insertAfter(element.closest('.input-icon'));
                },

                submitHandler: function (form) {

                    $.ajax({

                        data: {email: $("#email").val(), password: $("#password").val()},
                        url: "${basePath}/auth/admin/login.json",

//	    			async: false,
                        type: 'POST',
                        dataType: 'json',
                        success: function (data) {
                            console.log(data);
                            if (data.result) {
                                location.href = "${basePath}/admin/index.htm";
                            } else {
                                $('.alert-danger span', $('.login-form')).html(data.msg);
                                $('.alert-danger', $('.login-form')).show();

                            }
                        }
                    });
                }
            });

            $('.login-form input').keypress(function (e) {
                if (e.which == 13) {
                    if ($('.login-form').validate().form()) {
                        $('.login-form').submit();
                    }
                    return false;
                }
            });
        }


        return {

            init: function () {

                handleLogin();
                $.backstretch([
                    "${basePath}/assets/admin/pages/media/bg/1.jpg",
                    "${basePath}/assets/admin/pages/media/bg/2.jpg",
                    "${basePath}/assets/admin/pages/media/bg/3.jpg",
                    "${basePath}/assets/admin/pages/media/bg/4.jpg"
                ], {
                    fade: 1000,
                    duration: 8000
                });
            }

        };

    }();
</script>
<!-- END JAVASCRIPTS -->
</body>

